using Game.Const;
using Game.Core;
using Game.Main.Model;
using Game.Manager;
using UnityEngine;

namespace Game.Component
{
	public class PackingBoxItem : BaseItem
	{
		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override void QuicklyTouch(TouchEventData touchEventData)
		{
			base.QuicklyTouch(touchEventData);
			for (int num = childItems.Count - 1; num >= 0; num--)
			{
				BaseItem baseItem = childItems[num];
				ReleaseAttachItem(baseItem);
				baseItem.SetPosition(base.transform.position.x, base.transform.position.y, base.transform.position.z);
				baseItem.DropDown(base.transform.position, true);
			}
			GlobalEventSystem.Fire(new BaseEvent("game.remove_item", archiveData.index));
			Singleton<AudioManager>.Instance.PlaySound("sound_explode");
			Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + base.itemData.effect, base.transform.position + new Vector3(0f, 0f, -0.0004f), 1f);
			Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_blink_1", base.transform.position + new Vector3(0f, 0f, -0.0004f), 3f);
		}

		public override bool AttachItem(BaseItem item, DepthType depthType, AttachType attachType, bool updatePosition)
		{
			if (attachType == AttachType.Pack)
			{
				item.SetVisible(false);
			}
			return base.AttachItem(item, depthType, attachType, updatePosition);
		}

		public override void ReleaseAttachItem(BaseItem item)
		{
			if (item.attachType == AttachType.Pack)
			{
				item.SetVisible(true);
			}
			base.ReleaseAttachItem(item);
		}
	}
}
